package com.cy.springcloud.fallbackFactorys;

import com.cy.springcloud.services.HelloService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Description: 调用远程服务的hello接口失败时的回调类，带异常信息
 * @ClassName: HelloFallbackFactory
 * @Author: chenyu
 * @Date: 2025/1/7 15:15
 */
@Component
public class HelloFallbackFactory implements FallbackFactory<HelloService> {

    @Override
    public HelloService create(Throwable throwable) {
        return new HelloService() {
            @Override
            public String hello() {
                return throwable.getMessage();
            }
        };
    }
}
